<template>
  <div class="RecentPlay">
    <div class="Top">
      <div class="left">
        <span>最近播放</span>
        <span>共{{ total }}首</span>
      </div>
      <div class="right">
        <span @click="clearList">清空列表</span>
      </div>
    </div>
    <MyButton :list="data"></MyButton>
    <Table :tableData="data" :config="config"></Table>
  </div>
</template>

<script>
import Table from '@/components/table/Table';
import MyButton from '@/components/mybutton/MyButton';
export default {
  data() {
    return {
      total: 0,
      data: [],
      //表格参数配置
      config: {
        width: 300,
        showTodos: false,
        showAlbum: true,
      },
    };
  },
  components: { Table, MyButton },
  created() {
    this.getRecent();
  },

  methods: {
    async getRecent() {
      const { data } = await this.$request('/record/recent/song');
      this.total = data.total;
      data.list.forEach((item) => {
        this.data.push(item.data);
      });
    },
    clearList() {
      this.total = 0;
      this.data = [];
    },
  },
};
</script>

<style scoped='scoped' lang='scss'>
.RecentPlay {
  .Top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: solid 1px $grayHover;
    .left {
      :first-child {
        font-size: 20px;
        font-weight: 600;
        margin-right: 10px;
      }
      :last-child {
        font-size: 13px;
        color: #919191;
      }
    }
    .right {
      span {
        color: $userBlue;
        cursor: pointer;
        &:hover {
          color: $userHover;
        }
      }
    }
  }
}
</style>